package com.blink.zkclient.operate;

import com.blink.base.TestZK;
import com.blink.zkclient.ZkClientCreator;
import org.I0Itec.zkclient.ZkClient;
import org.junit.jupiter.api.Test;

import java.util.concurrent.TimeUnit;

/**
 * <Description> ZkClient检测节点是否存在</Description>
 * <ClassName> ExistNodeSample</ClassName>
 *
 * @Author liuxianzhao
 * @Date 2018年01月13日 13:25
 */
public class ExistNodeSample extends TestZK {
    @Test
    public void testExistNode() {
        ZkClient zkClient = ZkClientCreator.getZkClient();
        String path = "/zk-book";
        logger.info("Node " + path + " exists :" + zkClient.exists(path));
        boolean exists = zkClient.waitUntilExists(path, TimeUnit.MINUTES, 1);
        logger.info("Node " + path + " exists :" + exists);
        sleep();
    }
}
